language :ruby do
  rule 'Space should be around block { |param| foo }' do
    pattern /[\.\s]#{block_not_padded}/

    collapse_hashes
    collapse_quotes
  end

  rule 'No spaces after (, [ or before ], )' do
    collapse_quotes

    def self.no_spaces_padding_parens
      space = /[ ]/
      left_parens = /[\[\(]/
      right_parens = /[\]\)]/
      space_after_left_parens = /#{left_parens}#{space}/
      space_before_right_parens =
      /^(?!\s+#{right_parens}).*#{space}#{right_parens}/
      /(?:#{space_after_left_parens}|#{space_before_right_parens})/
    end

    pattern no_spaces_padding_parens
  end

  rule 'Parentheses should be around function parameters' do
    pattern /def \w+ \w/
  end
end
